home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / usr / sbin / mkbiospkg.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2008-08-26  |  2KB  |  78 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. binary=/usr/sbin/dellBiosUpdate
  6. pkgHeader=pkgheader.sh
  7. biosHdr=$1
  8. output=pkg.bin
  9.  
  10. usage()
  11. {
  12.     echo "mkbiospkg -o OUTPUT_FILE -b BIOS.HDR -p PACKAGE_HEADER"
  13.     echo
  14. }
  15.  
  16. while getopts "o:b:p:h" Option
  17. do
  18.   case $Option in
  19.       o)
  20.         output=$OPTARG
  21.         ;;
  22.       b)
  23.         biosHdr=$OPTARG
  24.         ;;
  25.       p)
  26.         pkgHeader=$OPTARG
  27.         ;;
  28.       *) 
  29.         usage
  30.         ;;
  31.   esac
  32. done
  33. shift $(($OPTIND - 1))
  34. # Move argument pointer to next.
  35.  
  36. if [ ! -e "$biosHdr" ]; then
  37.     echo "Require BIOS.HDR to create package."
  38.     exit 1
  39. fi
  40.  
  41. if [ ! -e "$pkgHeader" ]; then
  42.     echo "Require package header to create package."
  43.     exit 1
  44. fi
  45.  
  46. libs=$( ldd $binary | grep '=>' | cut -d'>' -f2 | perl -p -i -e 's/\(.*\)//;' )
  47. tmpdir=$(mktemp -d /tmp/mkpkg-XXXXXX)
  48. tempTgz=$(mktemp /tmp/mkpkg-tgz-XXXXXX)
  49. trap 'rm -rf $tmpdir' HUP EXIT QUIT TERM
  50.  
  51. for file in $libs $binary;
  52. do
  53.     rpm=$(rpm -qf --qf '%{name}-%{version}-%{release}.%{arch}' $file)
  54.     srpm=$(rpm -qi $rpm | grep "Source RPM" | cut -d: -f3 )
  55.     echo "$file  ==>  $srpm" >> $tmpdir/file-srpm-sources.txt
  56.     echo $srpm >> $tmpdir/srpms.txt
  57. done
  58.  
  59. echo "======================"
  60. echo "SRPM List:"
  61. cat $tmpdir/srpms.txt | sort | uniq > $tmpdir/srpms.txt2
  62. mv $tmpdir/srpms.txt2 $tmpdir/srpms.txt
  63. cat $tmpdir/srpms.txt
  64. echo "======================"
  65. echo 
  66.  
  67. cp $binary $libs $tmpdir/
  68. cp $biosHdr $tmpdir/bios.hdr
  69.  
  70. tar czf $tempTgz -C $tmpdir .
  71.  
  72. cp $pkgHeader $output
  73. cat $tempTgz >> $output
  74.  
  75. echo "Successfully Created $output"
  76. echo
  77.  
  78.